﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PMS.ENT;
using PMS.DAL;

namespace PMS.BLL
{
    public class ScheduleBLL
    {
        #region Get
        public static ScheduleENT GetScheduleByID(int scheduleID)
        {
            try
            {
                return ScheduleDAL.GetScheduleByID(scheduleID);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static ScheduleCollection GetScheduleList(string scheduleName, int projectID, int semesterID, int userID, string status, string orderBy, string orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                return ScheduleDAL.GetScheduleList(scheduleName, projectID, semesterID, userID, status, orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static ScheduleCollection GetScheduleListForCMB(int userID, int projectID,int semesterID)
        {
            try
            {
                ScheduleCollection listSchedule = new ScheduleCollection();
                listSchedule.Add(new ScheduleENT { ScheduleID = 0, ScheduleName = "--All--" });
                listSchedule.AddRange(ScheduleDAL.GetScheduleListForCMB(userID, projectID,semesterID));
                return listSchedule;
            }
            catch (Exception)
            {

                throw;
            }


        }


        #endregion

        #region Insert Update Delete Confirm

        public static int InsertSchedule(ScheduleENT schedule)
        {
            try
            {
                return ScheduleDAL.InsertSchedule(schedule);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int UpdateSchedule(ScheduleENT schedule)
        {
            try
            {
                return ScheduleDAL.UpdateSchedule(schedule);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int DeleteSchedule(string scheduleID, int userID)
        {
            try
            {
                return ScheduleDAL.DeleteSchedule(scheduleID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int ConfirmSchedule(string scheduleID, int userID)
        {
            try
            {
                return ScheduleDAL.ConfirmSchedule(scheduleID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int JoinSchedule(int scheduleID, int groupID, int userID)
        {
            try
            {
                return ScheduleDAL.JoinSchedule(scheduleID, groupID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int UnJoinSchedule(int scheduleID, int groupID, int userID)
        {
            try
            {
                return ScheduleDAL.UnJoinSchedule(scheduleID, groupID, userID);
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        #endregion

        #region Validate

        public static bool CheckIsOwnAndDraft(int[] scheduleID, int userID)
        {
            try
            {
                return ScheduleDAL.CheckIsOwnAndDraft(scheduleID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static bool CheckScheduleStatus(int[] scheduleID, string status)
        {
            try
            {
                return ScheduleDAL.CheckScheduleStatus(scheduleID, status);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static ScheduleENT CheckIsSchedule(int projectID, int groupID, int semesterID)
        {
            try
            {
                return ScheduleDAL.CheckIsSchedule(projectID, groupID, semesterID);
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        #endregion
    }
}
